// 记分牌
class ScorePanel {

  // 定义分数
  score = 0
  // 定义等级
  level = 1
  // 定义保存的元素
  scoreEle: Element
  levelEle: Element

  // 设置最高等级变量
  maxLevel: number
  // 设置需要多少分才可升级
  upScore: number


  constructor(maxLevel = 10, upScore = 10) {
    this.scoreEle = document.getElementById('score')!
    this.levelEle = document.getElementById('level')!
    this.maxLevel = maxLevel
    this.upScore = upScore
  }

  // 加分函数
  addScore() {
    this.scoreEle.innerHTML = ++this.score + ''

    // 升级
    if(this.score % this.upScore === 0 && this.level < this.maxLevel) {
      this.levelEle.innerHTML = ++this.level + ''
    }
  }

}

export default ScorePanel